#include<iostream>
#include<string>
using namespace std;
string s;
const int N = 1010;
int f[N][N];
int main()
{
	cin >> s;
	int n = s.size();
	s = " " + s;
	
	for (int len = 2;len <= n;len++)//如果len==1,那么i==j就重合了，不用计算
	{
		for (int i = 1;i + len - 1 <= n;i++)
		{
			int j = i + len - 1;
			if (s[i] == s[j]) f[i][j] = f[i + 1][j - 1];
			else
			{
				f[i][j] = min(f[i + 1][j], f[i][j - 1]) + 1;
			}
		}
	}
	cout << f[1][n] << endl;
	return 0;
}